home *** CD-ROM | disk | FTP | other *** search
- From: "john (j.d.) hickin" <hickin@bnr.ca>
- Message-ID: <4jucle$i41@bmtlh10.bnr.ca>
- X-Original-Date: Wed, 3 Apr 1996 17:31:26 +0000
- Path: in1.uu.net!bounce-back
- Date: 05 Apr 96 02:13:52 GMT
- Approved: fjh@cs.mu.oz.au
- References: <009A04DA6A831C40.49800EAC@ittpub.nl>
- Subject: Re: sample auto_ptr template
- Newsgroups: comp.std.c++
- Organization: Bell Northern Research
- X-Mailer: Mozilla 1.1 (X11; I; HP-UX A.09.05 9000/715)
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMWSCHuEDnX0m9pzZAQHrcQF/YsQNbvrZH6RGfcX5M6fXK0WhFkXqWHQl
- Dbz1gTCrY6N5xvk2+L1J+bjGqEEYI1DB
- =MKTT
-
- |> This is a terrible state of affairs, especially when we realize
- |> auto_ptr is the *only* smart pointer we have in the standard library.
- |> In my opinion, it should be renamed to zombie_ptr if it is to keep its
- |> new semantics.
-
- It all depends what you want to use an auto_ptr for. I have used classes
- like this way before templates or exception handling were added to C++.
- The main use was as insurance that certain resources were released on exit
- from a block in the face of multiple exit paths from the block.
-
- The January DWP continues to say that auto_ptr provides strict ownership
- semantics [20.4.5 Template class auto_ptr]:
-
- 2 The auto_ptr provides a semantics of strict ownership. An object may
- be safely pointed to by only one auto_ptr, so copying an auto_ptr
- copies the pointer and transfers ownership to the destination.
-
- The implementation you have quoted does not contradict the above statement.
- The January version of auto_ptr had the owner's stored pointer set to 0 so
- that dereferencing under such conditions was not allowed:
-
- X& operator*() const;
-
- Requires:
- get() != 0
- Returns:
- *get()
-
- A simple amendment to the DWP, perhaps already in the works, is all we require:
-
-
- X& operator*() const;
-
- Requires:
- owner == true
- Returns:
- *get()
-
- With change, dereferencing will, as before, be undefined when ownership is
- not held.
-
-
- --
- John Hickin Nortel Technology, Montreal, Quebec
- (514) 765-7924 hickin@nortel.ca
- ---
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-